﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>岗位管理</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="../Static/jquery-1.6.2.min.js" type="text/javascript"></script>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <script src="../Static/boot.js" type="text/javascript"></script>
    <link href="../Static/demo.css" rel="stylesheet" />
    <link href="../Static/miniui/themes/blue/skin.css" rel="stylesheet" />

    <style type="text/css">
        html, body {
            font-size: 12px;
            padding: 0;
            margin: 0;
            border: 0;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div class="mini-fit">
        <div class="mini-toolbar">
            <span>区域：</span>
            <input type="text" id="txt_CategoryName" class="mini-textbox" style="width: 120px" />
            <a class="mini-button" onclick="search()" iconcls="icon-search">查询</a>
            <a class="mini-button" onclick="clearWhere()" iconcls="icon-remove">清空条件</a>
        </div>
        <div id="grid" class="mini-datagrid" style="width: 100%; height: 310px;" allowresize="true"
             showcolumnsmenu="true" url="/AdminMana/Ajax/AjaxService.aspx?method=GetCategory" idfield="ID"
             onselectionchanged="onSelectionChanged" showcolumnsmenu="true" pagesize="100">
            <div property="columns">
                <div type="indexcolumn" width="10">
                    序
                </div>
                <div field="ID" width="30" headeralign="center">
                    ID
                </div>
                <div field="CategoryName" width="100" headeralign="center">
                    区域
                </div>
                <div field="Sort" width="100" headeralign="center">
                    排序
                </div>
            </div>
        </div>
        <fieldset style="width: 98%; border: solid 1px #aaa; position: relative;">
            <legend>详细信息</legend>
            <div id="editForm1" style="padding: 5px;">
                <!--ID-->
                <input style="display:none" id="hn_ID" />
                <table style="width: 800px;">

                    <tr>
                        <td style="width: 180px;text-align:right">
                            <span style="color: Red; font-size: 12px">
                                操作状态：
                            </span>
                        </td>
                        <td>
                            <input id="txt_Aciton" type="text" class="mini-textbox" style="width: 150px;" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 180px;text-align:right">
                            岗位名称：
                        </td>
                        <td>
                            <input id="CategoryName" name="CategoryName" class="mini-textbox" style="width: 400px;" />
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 180px;text-align:right">
                            排序：
                        </td>
                        <td>
                            <input id="Sort" name="Sort" type="text" vtype="int" required="true" class="mini-textbox" style="width: 150px;" />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: center; padding-top: 5px; padding-right: 200px;" colspan="4">

                            <a class="mini-button" onclick="AddNew()" iconcls="icon-add">新增</a>
                            <span class="separator"></span>
                            <a class="mini-button" onclick="Save()" iconcls="icon-save">保存</a>
                            <span class="separator"></span>
                            <a class="mini-button" onclick="Del()" iconcls="icon-cancel">删除</a>
                            <input id="hn_action" style="display:none" value="" />

                        </td>
                    </tr>
                </table>
            </div>
        </fieldset>
    </div>

    <script type="text/javascript">

        mini.parse();
        var grid = mini.get("grid");
        grid.load();

        mini.get("txt_Aciton").setEnabled(false);
        var editForm = document.getElementById("editForm1");
        var form = new mini.Form("editForm1");

        /**点击行加载信息*********************************************************************/
        function onSelectionChanged(e) {
            var data = grid.getSelected();
            if (data != null) {
                mini.get("txt_Aciton").setValue("");
                mini.get("txt_Aciton").setValue("修改");
                document.getElementById("hn_action").value = "Update";//点击状态:修改
                document.getElementById("hn_ID").value = data.ID; // ID

                mini.get("CategoryName").setValue(data.CategoryName);
                mini.get("Sort").setValue(data.Sort);
            }


        }
        /**查询******************************************************************************/
        function search() {
            var categoryName = mini.get("txt_CategoryName").getValue();
            grid.load({
                key: categoryName
            });
        }
        //-----------------------------清空条件-------------------------
        function clearWhere() {
            mini.get("txt_CategoryName").setValue("");
        }
        $("#txt_CategoryName").bind("keydown", function (e) {
            if (e.keyCode == 13) {
                search();
            }
        });

        //新增---------------------------------------------------------
        function AddNew() {
            mini.get("txt_Aciton").setValue("");
            mini.get("txt_Aciton").setValue("新增");
            document.getElementById("hn_action").value = "Insert";
            $("#hn_ID").val("");
            mini.get("CategoryName").setValue("");
            mini.get("Sort").setValue("");
        }
        //删除---------------------------------------------------------
        function Del() {
            if (document.getElementById("hn_ID").value == "") {
                mini.alert("未选中任何区域！");
                return;
            }
            document.getElementById("hn_action").value = "Delete";

            if (mini.confirm("确定删除选中记录？")) {
                Save();
            }
        }
        //保存---------------------------------------------------------
        function Save() {
            var action = document.getElementById("hn_action").value;
            if (action == "") {
                mini.alert("请先选择操作状态");
                return false;
            }
            form.validate();
            if (form.isValid() == false) return;


            $.ajax({
                url: "/AdminMana/Ajax/AjaxService.aspx?method=EidtCategory",
                data: {
                    Action: action,
                    id: $("#hn_ID").val(),
                    categoryName: mini.get("CategoryName").getValue(),
                    Sort: mini.get("Sort").getValue()
                },
                cache: false,
                success: function (text) {
                    var o = mini.decode(text);
                    if (o.res != "操作成功") {
                        mini.alert("操作失败");
                    }
                    grid.reload();
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);

                }
            });
        }
    </script>

</body>
</html>
